﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mangosoft.DiceCopy.Presentation.Domain.Contracts;
using Mangosoft.DiceCopy.Presentation.Domain.Models;
using Mangosoft.DiceCopy.Presentation.Domain.JobHuntingModuleService;

namespace Mangosoft.DiceCopy.Presentation.Domain.Agents {
    public class NewsAgent : INewsAgent {
        public List<NewsModel> GetNewsByChannel(int channel) {
            var client = new JobHuntingModuleServiceClient();
            var newsData = client.FindNewsByChannel(channel)
                .Select(n => new NewsModel {
                    Channel = n.Channel,
                    Title = n.Title,
                    NavigateUrl = n.NavigateUrl,
                    PostedOn = n.PostedOn
                }).ToList();

            client.Close();


            return newsData;
        }
    }
}
